package model

import "database/sql"

type ProductProduct struct {
	ResCommon
	ProductTmplId               int64 `json:"product_tmpl_id"`
	ProductTmpl                 ProductTemplate
	CombinationIndices          string `json:"combination_indices"`
	Active                      bool
	DefaultCode                 string
	Barcode                     string
	Volume                      float64
	Weight                      float64
	CanImageVariant1024BeZoomed bool `gorm:"column:can_image_variant_1024_be_zoomed"`
	AvataxCategoryId            sql.NullInt64
}

type ProductTemplate struct {
	ResCommon
	Name              string  `json:"name"`
	ListPrice         float64 `json:"list_price"`
	SaleOk            bool    `json:"sale_ok"`
	IsPublished       bool    `json:"is_published"`
	CategId           int64   `json:"categ_id"`
	AttributeDescribe string  `json:"attribute_describe"`
	Description       string  `json:"description"`
	Categ             ProductCategory
	BrandId           int64
	Brand             ProductBrand
	UomPoId           int64         `json:"uom_po_id" gorm:"default:1"`
	UomId             sql.NullInt64 //单位
	DefaultCode       sql.NullString
	SalesQty          sql.NullInt64  //销售数量
	Origin            sql.NullString //产地
	Attribute         sql.NullString //属性
}

// ProductCategory 产品分类
type ProductCategory struct {
	ResCommon
	Name         string
	CompleteName string
	ParentId     int64
	ParentPath   string
}
type ProductPublicCategory struct {
	ResCommon
	Name       string
	ParentId   int64
	ParentPath string
}
type ProductPublicCategoryProductTemplateRel struct {
	ProductPublicCategoryId int64
	ProductTemplateId       int64
}

// ProductBrand 产品品牌
type ProductBrand struct {
	ResCommon
	Name    string
	NameEng string
	Rank    string
	Active  bool
	TeamId  int64
}

// ProductAttribute 产品属性
type ProductAttribute struct {
	ResCommon
	Name          string
	Sequence      int
	CreateVariant string
	DisplayType   string
	Visibility    string
	Values        []ProductAttributeValue `gorm:"foreignKey:AttributeId"`
}

// ProductAttributeValue 产品属性值
type ProductAttributeValue struct {
	ResCommon
	Name        string
	Sequence    int
	AttributeId int64
	Attribute   ProductAttribute
	IsCustom    sql.NullBool
	HtmlColor   sql.NullString
	Color       int
	PriceUnit   float64
	Note        sql.NullString
}

// ProductAttributeProductTemplateRel 产品属性关联表
type ProductAttributeProductTemplateRel struct {
	ProductAttributeId int64
	ProductTemplateId  int64
}

// ProductTemplateAttributeLine 产品属性值数量
type ProductTemplateAttributeLine struct {
	ResCommon
	Active        bool
	ProductTmplId int64
	AttributeId   int64
	ValueCount    int
}

// ProductTemplateAttributeValue 产品属性值价格
type ProductTemplateAttributeValue struct {
	ResCommon
	PtavActive              bool
	ProductAttributeValueId int64 //产品属性值
	ProductAttributeValue   ProductAttributeValue
	AttributeLineId         int64
	PriceExtra              float64 //额外价格
	ProductTmplId           int64
	AttributeId             int64
	Attribute               ProductAttribute
	Color                   string
}

type ProductImage struct {
	ResCommon
	Name                 string
	Sequence             int
	ProductTmplId        int64
	ProductVariantId     sql.NullInt64
	CanImage1024BeZoomed bool `gorm:"default:true;column:can_image_1024_be_zoomed"`
}

// ProductVariantCombination 产品变体和属性值关系表
type ProductVariantCombination struct {
	ProductProductId                int64
	ProductTemplateAttributeValueId int64
}
